package com.ll.webapi.springbootannotation.controller;


import com.ll.webapi.springbootannotation.entity.FilmInfo;
import com.ll.webapi.springbootannotation.service.IFilmInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ll
 * @since 2021-03-15
 */
@RestController
@RequestMapping("/film-info")
public class FilmInfoController {

    @Autowired
    private IFilmInfoService iFilmInfoService;

    /**
     * 顾名思义,请求映射,如果不指定具体的请求方法,则默认接收所有类型的请求
     * @return
     */
    @RequestMapping("getFilmInfoList")
    public List<FilmInfo> getFilmInfoList() {
        List<FilmInfo> list = iFilmInfoService.list();
        return list;

    }

    /**
     * 处理get请求
     * @RequestMapping(method = {RequestMethod.GET})的简写
     * @param id
     * @return
     */
    @GetMapping("getFilmInfo/{id}")
    public FilmInfo getFilmInfo(@PathVariable("id") Integer id) {
        FilmInfo filmInfo = iFilmInfoService.getById(id);
        return filmInfo;
    }




}

